package com.tqq.onlinetest.service.impl;

import com.tqq.onlinetest.dao.StudentInfoMapper;
import com.tqq.onlinetest.dao.StudentMapper;
import com.tqq.onlinetest.pojo.Student;
import com.tqq.onlinetest.pojo.StudentInfo;
import com.tqq.onlinetest.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentImpl implements StudentService {
    @Autowired
    private StudentMapper studentMapper;
    @Autowired
    private StudentInfoMapper studentInfoMapper;


    @Override
    public boolean addStudentInfo(StudentInfo studentInfo) {
        int i=studentInfoMapper.insertSelective(studentInfo);
//        插入失败
        if(i!=1) return false;
        else  return true;

    }

    @Override
    public boolean deleteStudentInfoById(String id) {
        int i=studentInfoMapper.deleteByPrimaryKey(id);
        if(i!=1) return false;
        else  return true;
    }

    @Override
    public boolean updateStudentInfo(StudentInfo studentInfo) {
        int i=studentInfoMapper.updateByPrimaryKeySelective(studentInfo);
        if(i!=1) return false;
        else  return true;
    }

    @Override
    public StudentInfo getStudentInfoByID(String id) {
       return studentInfoMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<StudentInfo> getAllStudentInfo() {
       return studentInfoMapper.getAllStudentInfo();
    }

    @Override
    public Student getStudentLoginById(String id) {
        return studentMapper.selectByPrimaryKey(id);
    }
}
